package com.xh3140.android.widget.dialog.params;


import android.content.Context;

import androidx.annotation.NonNull;

import java.util.Arrays;

/**
 * 配置属性抽象类
 */
public abstract class AbstractParams {
    public final Context context;
    public final float density;

    public AbstractParams(@NonNull Context context) {
        this.context = context;
        this.density = context.getResources().getDisplayMetrics().density;
    }

    protected int dp2px(int dp) {
        return (int) (dp * density);
    }

    protected int[] dps2pxs(int... dps) {
        final int[] pxs = Arrays.copyOf(dps, dps.length);
        for (int i = 0; i < pxs.length; ++i) {
            pxs[i] = (int) (pxs[i] * density);
        }
        return pxs;
    }
}